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

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

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

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

e = A("e")
l = B("l")
d = C("d")
j = D("j")
k = D("k")

e.t = d
e.p = j
l.q = j
l.o = e
l.p = e
d.u = l
j.y = l
k.y = l
assert d.u.p.t.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: D = None
        self.txt = txt

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

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

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

e = A("e")
l = B("l")
d = C("d")
j = D("j")
k = D("k")

e.t = d
e.p = j
l.q = j
l.o = e
l.p = e
d.u = l
j.y = l
k.y = l
assert d.u.p.t.u.o.txt == "e"