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

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

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

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

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

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

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

b.t = m
b.q = h
m.p = h
h.o = d
i.p = h
i.w = m
a.r = b
a.u = b
d.q = m
d.z = b
assert a.r.t.p.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

b.t = m
b.q = h
m.p = h
h.o = d
i.p = h
i.w = m
a.r = b
a.u = b
d.q = m
d.z = b
assert a.r.t.p.o.z.txt == "b"