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

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

d = A("d")
a = B("a")
j = A("j")
i = B("i")
h = B("h")
m = B("m")
c = A("c")
k = B("k")
n = A("n")

d.u = c
d.x = i
a.v = n
a.r = n
j.u = n
j.x = h
i.v = d
i.r = d
h.v = n
h.r = d
m.v = n
m.r = n
c.u = d
c.x = a
k.v = d
k.r = d
n.u = d
n.x = i
assert k.r.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: B = None
        self.txt = txt

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

d = A("d")
a = B("a")
j = A("j")
i = B("i")
h = B("h")
m = B("m")
c = A("c")
k = B("k")
n = A("n")

d.u = c
d.x = i
a.v = n
a.r = n
j.u = n
j.x = h
i.v = d
i.r = d
h.v = n
h.r = d
m.v = n
m.r = n
c.u = d
c.x = a
k.v = d
k.r = d
n.u = d
n.x = i
assert k.r.u.u.u.txt == "c"