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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: F = None
        self.y: B = None
        self.u: E = None
        self.p: F = None
        self.r: D = None
        self.w: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.v: A = None
        self.txt = txt

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

a = A("a")
c = B("c")
j = C("j")
g = D("g")
d = E("d")
n = F("n")

a.p = d
a.y = j
a.u = n
c.o = g
j.t = n
j.p = n
j.y = c
j.u = d
j.w = d
j.r = g
g.q = n
d.p = n
d.v = a
n.p = g
n.r = c
n.z = j
assert a.u.z.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.y: C = None
        self.u: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: F = None
        self.y: B = None
        self.u: E = None
        self.p: F = None
        self.r: D = None
        self.w: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.v: A = None
        self.txt = txt

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

a = A("a")
c = B("c")
j = C("j")
g = D("g")
d = E("d")
n = F("n")

a.p = d
a.y = j
a.u = n
c.o = g
j.t = n
j.p = n
j.y = c
j.u = d
j.w = d
j.r = g
g.q = n
d.p = n
d.v = a
n.p = g
n.r = c
n.z = j
assert a.u.z.r.q.txt == "n"