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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

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

e = A("e")
d = B("d")
b = C("b")
m = D("m")
k = E("k")
h = F("h")
c = D("c")

e.p = b
e.u = k
d.w = e
b.w = c
b.p = h
b.r = h
b.q = d
m.o = e
k.u = c
h.w = b
h.t = d
h.r = k
c.o = e
assert e.u.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

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

e = A("e")
d = B("d")
b = C("b")
m = D("m")
k = E("k")
h = F("h")
c = D("c")

e.p = b
e.u = k
d.w = e
b.w = c
b.p = h
b.r = h
b.q = d
m.o = e
k.u = c
h.w = b
h.t = d
h.r = k
c.o = e
assert e.u.u.o.u.txt == "k"