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

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

j = A("j")
l = B("l")
g = B("g")
c = A("c")
b = A("b")
h = B("h")
f = A("f")

j.u = b
j.t = c
l.p = j
g.p = f
c.u = f
c.t = f
b.u = f
b.t = c
h.p = c
f.u = j
f.t = j
assert l.p.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: A = None
        self.txt = txt

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

j = A("j")
l = B("l")
g = B("g")
c = A("c")
b = A("b")
h = B("h")
f = A("f")

j.u = b
j.t = c
l.p = j
g.p = f
c.u = f
c.t = f
b.u = f
b.t = c
h.p = c
f.u = j
f.t = j
assert l.p.t.u.txt == "f"