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

class B:
    def __init__(self, txt: str):
        self.s: F = None
        self.y: E = None
        self.v: D = 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.q: F = None
        self.u: A = None
        self.s: F = None
        self.z: B = None
        self.y: E = None
        self.p: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: E = None
        self.q: B = None
        self.u: D = None
        self.txt = txt

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

l = A("l")
c = B("c")
j = C("j")
h = D("h")
n = E("n")
d = F("d")
i = C("i")
m = E("m")

l.r = n
c.s = d
c.y = m
c.v = h
j.r = c
h.q = d
h.s = d
h.u = l
h.p = l
h.z = c
h.y = n
n.x = m
n.q = c
n.u = h
d.y = l
i.r = c
m.x = n
m.q = c
m.u = h
assert n.u.y.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: F = None
        self.y: E = None
        self.v: D = 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.q: F = None
        self.u: A = None
        self.s: F = None
        self.z: B = None
        self.y: E = None
        self.p: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: E = None
        self.q: B = None
        self.u: D = None
        self.txt = txt

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

l = A("l")
c = B("c")
j = C("j")
h = D("h")
n = E("n")
d = F("d")
i = C("i")
m = E("m")

l.r = n
c.s = d
c.y = m
c.v = h
j.r = c
h.q = d
h.s = d
h.u = l
h.p = l
h.z = c
h.y = n
n.x = m
n.q = c
n.u = h
d.y = l
i.r = c
m.x = n
m.q = c
m.u = h
assert n.u.y.x.q.txt == "c"