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

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

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

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

e = A("e")
i = B("i")
k = C("k")
f = D("f")
h = C("h")
b = A("b")

e.t = h
i.x = h
i.s = h
i.q = e
i.o = k
k.p = f
k.s = h
f.t = k
h.p = f
h.s = k
b.t = h
assert f.t.s.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

e = A("e")
i = B("i")
k = C("k")
f = D("f")
h = C("h")
b = A("b")

e.t = h
i.x = h
i.s = h
i.q = e
i.o = k
k.p = f
k.s = h
f.t = k
h.p = f
h.s = k
b.t = h
assert f.t.s.p.t.txt == "k"