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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: D = None
        self.u: B = None
        self.txt = txt

j = A("j")
m = B("m")
g = C("g")
a = D("a")
i = A("i")
h = D("h")
n = D("n")
k = D("k")
f = D("f")

j.x = i
m.y = i
m.t = g
m.w = g
m.v = j
g.p = m
g.q = i
a.v = j
a.o = f
a.u = m
i.x = j
h.v = j
h.o = k
h.u = m
n.v = j
n.o = k
n.u = m
k.v = j
k.o = f
k.u = m
f.v = j
f.o = k
f.u = m
assert a.v.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: D = None
        self.u: B = None
        self.txt = txt

j = A("j")
m = B("m")
g = C("g")
a = D("a")
i = A("i")
h = D("h")
n = D("n")
k = D("k")
f = D("f")

j.x = i
m.y = i
m.t = g
m.w = g
m.v = j
g.p = m
g.q = i
a.v = j
a.o = f
a.u = m
i.x = j
h.v = j
h.o = k
h.u = m
n.v = j
n.o = k
n.u = m
k.v = j
k.o = f
k.u = m
f.v = j
f.o = k
f.u = m
assert a.v.x.x.txt == "j"