class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.r: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: E = None
        self.o: E = None
        self.s: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: A = None
        self.y: C = None
        self.s: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

g = A("g")
f = B("f")
n = C("n")
i = D("i")
j = E("j")
a = F("a")
h = A("h")

g.p = i
g.r = i
f.u = n
f.y = n
f.r = n
f.s = n
n.p = f
n.r = f
i.v = f
i.p = j
i.o = j
i.s = a
j.v = h
j.x = h
j.y = n
j.s = a
a.y = n
h.p = i
h.r = i
assert j.x.r.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.r: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: E = None
        self.o: E = None
        self.s: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: A = None
        self.y: C = None
        self.s: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

g = A("g")
f = B("f")
n = C("n")
i = D("i")
j = E("j")
a = F("a")
h = A("h")

g.p = i
g.r = i
f.u = n
f.y = n
f.r = n
f.s = n
n.p = f
n.r = f
i.v = f
i.p = j
i.o = j
i.s = a
j.v = h
j.x = h
j.y = n
j.s = a
a.y = n
h.p = i
h.r = i
assert j.x.r.s.y.txt == "n"