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

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

m = A("m")
d = B("d")
k = B("k")
f = A("f")
l = A("l")
e = A("e")
c = B("c")

m.r = e
m.q = l
d.u = c
d.t = k
k.u = d
k.t = c
f.r = m
f.q = l
l.r = m
l.q = f
e.r = m
e.q = f
c.u = k
c.t = k
assert l.q.r.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: A = None
        self.txt = txt

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

m = A("m")
d = B("d")
k = B("k")
f = A("f")
l = A("l")
e = A("e")
c = B("c")

m.r = e
m.q = l
d.u = c
d.t = k
k.u = d
k.t = c
f.r = m
f.q = l
l.r = m
l.q = f
e.r = m
e.q = f
c.u = k
c.t = k
assert l.q.r.q.q.q.q.q.txt == "l"