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

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

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

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

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

a.y = b
a.w = b
a.v = m
m.y = a
m.w = b
b.x = a
b.z = f
b.p = e
f.t = k
k.t = f
e.y = a
e.w = b
assert b.p.y.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: C = None
        self.v: B = None
        self.txt = txt

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

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

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

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

a.y = b
a.w = b
a.v = m
m.y = a
m.w = b
b.x = a
b.z = f
b.p = e
f.t = k
k.t = f
e.y = a
e.w = b
assert b.p.y.v.y.v.txt == "m"