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

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: A = None
        self.v: C = None
        self.txt = txt

l = A("l")
n = B("n")
a = C("a")
b = D("b")
g = B("g")
d = A("d")
k = D("k")
f = C("f")

l.y = f
l.t = f
n.t = d
n.r = k
n.w = b
a.q = k
a.y = n
a.o = g
a.x = d
b.x = k
b.z = l
b.v = a
g.t = d
g.r = k
g.w = k
d.y = f
d.t = f
k.x = b
k.z = l
k.v = a
f.q = k
f.y = g
f.o = g
f.x = d
assert k.z.t.y.t.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: A = None
        self.v: C = None
        self.txt = txt

l = A("l")
n = B("n")
a = C("a")
b = D("b")
g = B("g")
d = A("d")
k = D("k")
f = C("f")

l.y = f
l.t = f
n.t = d
n.r = k
n.w = b
a.q = k
a.y = n
a.o = g
a.x = d
b.x = k
b.z = l
b.v = a
g.t = d
g.r = k
g.w = k
d.y = f
d.t = f
k.x = b
k.z = l
k.v = a
f.q = k
f.y = g
f.o = g
f.x = d
assert k.z.t.y.t.t.y.txt == "g"