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

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

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

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

f = A("f")
b = B("b")
l = C("l")
m = D("m")
c = C("c")
h = A("h")

f.w = l
f.z = m
b.s = h
b.p = h
b.v = c
b.z = m
l.t = b
l.r = c
l.x = c
m.z = b
m.x = l
c.t = b
c.r = l
c.x = l
h.w = l
h.z = m
assert l.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.z: D = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
l = C("l")
m = D("m")
c = C("c")
h = A("h")

f.w = l
f.z = m
b.s = h
b.p = h
b.v = c
b.z = m
l.t = b
l.r = c
l.x = c
m.z = b
m.x = l
c.t = b
c.r = l
c.x = l
h.w = l
h.z = m
assert l.t.v.t.txt == "b"