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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

f = A("f")
g = B("g")
b = C("b")
m = D("m")
l = A("l")
c = D("c")
i = D("i")
k = C("k")

f.r = b
g.s = l
g.u = k
g.r = c
b.v = k
m.p = g
l.r = b
c.p = g
i.p = g
k.v = b
assert m.p.u.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

f = A("f")
g = B("g")
b = C("b")
m = D("m")
l = A("l")
c = D("c")
i = D("i")
k = C("k")

f.r = b
g.s = l
g.u = k
g.r = c
b.v = k
m.p = g
l.r = b
c.p = g
i.p = g
k.v = b
assert m.p.u.v.v.v.txt == "b"