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

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.u: F = None
        self.z: A = None
        self.v: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.u: F = None
        self.z: A = None
        self.v: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

k.x = g
l.t = g
l.q = h
h.t = b
h.s = c
g.p = c
g.u = c
g.z = k
g.v = l
j.z = l
c.q = e
e.x = g
b.z = l
assert h.t.z.t.v.t.txt == "g"