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

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

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

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

a = A("a")
g = B("g")
f = C("f")
l = D("l")
h = B("h")

a.t = f
g.w = l
g.q = a
g.z = h
f.y = g
f.z = h
f.v = a
f.r = l
l.p = f
h.w = l
h.q = a
h.z = g
assert l.p.z.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
f = C("f")
l = D("l")
h = B("h")

a.t = f
g.w = l
g.q = a
g.z = h
f.y = g
f.z = h
f.v = a
f.r = l
l.p = f
h.w = l
h.q = a
h.z = g
assert l.p.z.w.p.txt == "f"