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

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

l = A("l")
m = B("m")
e = A("e")
d = A("d")
c = A("c")
j = A("j")
i = B("i")

l.u = d
m.p = i
m.t = i
e.u = l
d.u = e
c.u = e
j.u = e
i.p = m
i.t = m
assert c.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
e = A("e")
d = A("d")
c = A("c")
j = A("j")
i = B("i")

l.u = d
m.p = i
m.t = i
e.u = l
d.u = e
c.u = e
j.u = e
i.p = m
i.t = m
assert c.u.u.u.u.txt == "e"