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

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

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

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

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

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

g.v = n
k.r = d
k.u = d
c.r = n
c.u = j
d.v = g
a.r = j
a.u = d
l.r = g
l.u = n
n.v = j
j.v = g
assert k.r.v.v.v.v.v.v.v.txt == "g"