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

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

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

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

g = A("g")
j = B("j")
c = C("c")
m = D("m")
l = C("l")
f = A("f")

g.w = j
g.s = m
g.t = m
j.z = m
j.w = g
j.r = c
j.q = l
c.y = m
c.p = f
m.t = f
l.y = m
l.p = f
f.w = j
f.s = m
f.t = m
assert g.t.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
c = C("c")
m = D("m")
l = C("l")
f = A("f")

g.w = j
g.s = m
g.t = m
j.z = m
j.w = g
j.r = c
j.q = l
c.y = m
c.p = f
m.t = f
l.y = m
l.p = f
f.w = j
f.s = m
f.t = m
assert g.t.t.s.t.txt == "f"