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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.y: D = None
        self.z: C = None
        self.p: D = None
        self.txt = txt

l = A("l")
f = B("f")
e = C("e")
c = D("c")
h = E("h")
j = F("j")
a = B("a")
g = D("g")

l.s = c
f.x = g
f.q = l
e.u = f
c.t = a
h.u = e
j.s = e
j.z = e
j.t = l
j.y = c
j.p = g
a.x = g
a.q = l
g.t = a
assert a.q.s.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.y: D = None
        self.z: C = None
        self.p: D = None
        self.txt = txt

l = A("l")
f = B("f")
e = C("e")
c = D("c")
h = E("h")
j = F("j")
a = B("a")
g = D("g")

l.s = c
f.x = g
f.q = l
e.u = f
c.t = a
h.u = e
j.s = e
j.z = e
j.t = l
j.y = c
j.p = g
a.x = g
a.q = l
g.t = a
assert a.q.s.t.x.txt == "g"