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

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

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

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

f = A("f")
d = B("d")
k = C("k")
e = D("e")
m = B("m")

f.v = k
d.v = e
d.s = e
d.y = f
k.z = f
k.u = m
k.r = e
e.v = k
e.x = f
m.v = e
m.s = e
m.y = f
assert f.v.r.x.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
k = C("k")
e = D("e")
m = B("m")

f.v = k
d.v = e
d.s = e
d.y = f
k.z = f
k.u = m
k.r = e
e.v = k
e.x = f
m.v = e
m.s = e
m.y = f
assert f.v.r.x.v.u.txt == "m"