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

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: G = None
        self.z: F = None
        self.y: F = None
        self.q: A = None
        self.x: E = None
        self.t: F = None
        self.v: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: I = None
        self.s: I = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.x: I = None
        self.z: I = None
        self.txt = txt

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

a = A("a")
d = B("d")
c = C("c")
g = D("g")
f = E("f")
j = F("j")
n = G("n")
m = H("m")
k = I("k")

a.p = c
a.u = g
d.q = a
c.r = f
c.x = f
c.u = n
c.v = n
c.z = j
c.y = j
c.t = j
c.q = a
g.x = k
f.p = k
f.s = k
j.t = g
n.s = a
n.p = g
m.x = k
m.z = k
k.x = a
assert a.u.x.x.p.x.p.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: G = None
        self.z: F = None
        self.y: F = None
        self.q: A = None
        self.x: E = None
        self.t: F = None
        self.v: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: I = None
        self.s: I = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.x: I = None
        self.z: I = None
        self.txt = txt

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

a = A("a")
d = B("d")
c = C("c")
g = D("g")
f = E("f")
j = F("j")
n = G("n")
m = H("m")
k = I("k")

a.p = c
a.u = g
d.q = a
c.r = f
c.x = f
c.u = n
c.v = n
c.z = j
c.y = j
c.t = j
c.q = a
g.x = k
f.p = k
f.s = k
j.t = g
n.s = a
n.p = g
m.x = k
m.z = k
k.x = a
assert a.u.x.x.p.x.p.x.u.x.txt == "k"