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

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

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

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

c = A("c")
f = B("f")
k = C("k")
n = D("n")
g = D("g")
h = A("h")
l = A("l")
j = C("j")

c.y = n
c.w = g
c.x = f
c.o = j
f.t = n
f.r = k
k.r = f
n.z = g
g.z = n
h.y = n
h.w = g
h.x = f
h.o = j
l.y = g
l.w = g
l.x = f
l.o = k
j.r = f
assert n.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: D = None
        self.x: B = None
        self.o: C = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
k = C("k")
n = D("n")
g = D("g")
h = A("h")
l = A("l")
j = C("j")

c.y = n
c.w = g
c.x = f
c.o = j
f.t = n
f.r = k
k.r = f
n.z = g
g.z = n
h.y = n
h.w = g
h.x = f
h.o = j
l.y = g
l.w = g
l.x = f
l.o = k
j.r = f
assert n.z.z.z.txt == "g"