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

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

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

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

k = A("k")
c = B("c")
f = C("f")
n = D("n")
j = D("j")
b = A("b")
e = C("e")

k.u = c
k.v = c
c.v = b
c.s = n
c.r = n
f.r = e
n.r = f
j.r = f
b.u = c
b.v = c
e.r = f
assert c.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

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

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

k = A("k")
c = B("c")
f = C("f")
n = D("n")
j = D("j")
b = A("b")
e = C("e")

k.u = c
k.v = c
c.v = b
c.s = n
c.r = n
f.r = e
n.r = f
j.r = f
b.u = c
b.v = c
e.r = f
assert c.r.r.r.txt == "e"