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

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

g = A("g")
j = B("j")
k = B("k")
l = A("l")
f = A("f")
a = B("a")
c = A("c")
d = B("d")

g.u = a
g.t = f
j.t = d
j.v = k
k.t = d
k.v = a
l.u = k
l.t = f
f.u = d
f.t = l
a.t = d
a.v = d
c.u = j
c.t = f
d.t = a
d.v = k
assert d.v.t.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: A = None
        self.txt = txt

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

g = A("g")
j = B("j")
k = B("k")
l = A("l")
f = A("f")
a = B("a")
c = A("c")
d = B("d")

g.u = a
g.t = f
j.t = d
j.v = k
k.t = d
k.v = a
l.u = k
l.t = f
f.u = d
f.t = l
a.t = d
a.v = d
c.u = j
c.t = f
d.t = a
d.v = k
assert d.v.t.t.v.txt == "d"