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

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: C = None
        self.txt = txt

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

g = A("g")
l = B("l")
d = C("d")
n = D("n")
j = A("j")
k = C("k")
e = B("e")
m = D("m")
c = A("c")
h = A("h")

g.o = h
g.y = h
l.t = m
l.x = m
l.o = d
d.y = k
d.x = k
n.w = e
n.r = l
j.o = h
j.y = h
k.y = d
k.x = d
e.t = n
e.x = n
e.o = k
m.w = e
m.r = e
c.o = h
c.y = j
h.o = c
h.y = c
assert k.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: C = None
        self.txt = txt

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

g = A("g")
l = B("l")
d = C("d")
n = D("n")
j = A("j")
k = C("k")
e = B("e")
m = D("m")
c = A("c")
h = A("h")

g.o = h
g.y = h
l.t = m
l.x = m
l.o = d
d.y = k
d.x = k
n.w = e
n.r = l
j.o = h
j.y = h
k.y = d
k.x = d
e.t = n
e.x = n
e.o = k
m.w = e
m.r = e
c.o = h
c.y = j
h.o = c
h.y = c
assert k.x.x.x.txt == "d"