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

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

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

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

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

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

i = A("i")
c = B("c")
f = C("f")
d = D("d")
h = E("h")
b = F("b")
m = B("m")

i.q = c
i.x = f
i.t = f
i.p = f
c.y = f
f.t = d
d.r = i
h.q = d
h.z = i
h.y = i
b.v = i
b.u = i
b.r = i
b.y = i
b.p = f
m.y = f
assert d.r.x.t.r.q.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.t: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

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

i = A("i")
c = B("c")
f = C("f")
d = D("d")
h = E("h")
b = F("b")
m = B("m")

i.q = c
i.x = f
i.t = f
i.p = f
c.y = f
f.t = d
d.r = i
h.q = d
h.z = i
h.y = i
b.v = i
b.u = i
b.r = i
b.y = i
b.p = f
m.y = f
assert d.r.x.t.r.q.y.t.txt == "d"