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

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

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

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

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

i.y = f
i.t = f
f.s = g
f.x = g
f.p = l
f.t = c
n.z = i
n.t = f
l.s = g
l.y = m
m.y = f
m.t = g
c.z = i
c.t = g
g.s = f
g.x = f
g.p = l
g.t = n
assert c.t.s.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: B = None
        self.txt = txt

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

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

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

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

i.y = f
i.t = f
f.s = g
f.x = g
f.p = l
f.t = c
n.z = i
n.t = f
l.s = g
l.y = m
m.y = f
m.t = g
c.z = i
c.t = g
g.s = f
g.x = f
g.p = l
g.t = n
assert c.t.s.t.t.txt == "g"