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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
k = C("k")
j = A("j")
b = C("b")
m = A("m")
a = A("a")
e = B("e")

f.u = j
f.v = k
d.y = b
d.w = e
k.r = m
k.t = m
j.u = m
j.v = k
b.r = a
b.t = a
m.u = f
m.v = b
a.u = m
a.v = k
e.y = k
e.w = d
assert j.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
k = C("k")
j = A("j")
b = C("b")
m = A("m")
a = A("a")
e = B("e")

f.u = j
f.v = k
d.y = b
d.w = e
k.r = m
k.t = m
j.u = m
j.v = k
b.r = a
b.t = a
m.u = f
m.v = b
a.u = m
a.v = k
e.y = k
e.w = d
assert j.u.u.v.txt == "k"