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

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

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

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

e = A("e")
a = B("a")
l = C("l")
m = D("m")
j = A("j")

e.p = l
a.t = l
l.t = a
l.o = j
l.v = j
l.q = m
m.t = j
j.p = l
assert j.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

e = A("e")
a = B("a")
l = C("l")
m = D("m")
j = A("j")

e.p = l
a.t = l
l.t = a
l.o = j
l.v = j
l.q = m
m.t = j
j.p = l
assert j.p.o.p.txt == "l"