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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: D = None
        self.u: A = None
        self.txt = txt

i = A("i")
a = B("a")
c = C("c")
g = D("g")
e = E("e")
h = F("h")

i.z = g
i.u = g
a.u = i
a.q = i
a.v = c
c.r = h
g.t = i
e.u = c
e.z = a
e.t = i
h.w = e
h.o = g
h.u = i
assert h.u.z.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: D = None
        self.u: A = None
        self.txt = txt

i = A("i")
a = B("a")
c = C("c")
g = D("g")
e = E("e")
h = F("h")

i.z = g
i.u = g
a.u = i
a.q = i
a.v = c
c.r = h
g.t = i
e.u = c
e.z = a
e.t = i
h.w = e
h.o = g
h.u = i
assert h.u.z.t.u.txt == "g"