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

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

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

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

m = A("m")
c = B("c")
b = C("b")
f = D("f")
j = A("j")
a = B("a")

m.s = c
m.t = f
c.y = m
c.t = f
c.p = b
b.y = j
b.w = j
b.o = j
b.p = c
f.y = b
f.u = j
f.s = m
j.s = c
j.t = f
a.y = m
a.t = f
a.p = b
assert f.s.t.y.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
b = C("b")
f = D("f")
j = A("j")
a = B("a")

m.s = c
m.t = f
c.y = m
c.t = f
c.p = b
b.y = j
b.w = j
b.o = j
b.p = c
f.y = b
f.u = j
f.s = m
j.s = c
j.t = f
a.y = m
a.t = f
a.p = b
assert f.s.t.y.w.s.txt == "c"