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

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

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

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

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

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

g.x = c
g.r = l
a.v = i
a.s = d
c.x = j
c.r = l
i.x = l
i.r = j
d.v = c
d.s = a
l.x = i
l.r = c
j.x = i
j.r = i
k.v = j
k.s = d
assert j.r.r.x.x.x.txt == "i"